using Configuration.DataBase.Extensions;
using Configuration.Example;
using Microsoft.Extensions.Options;

var builder = WebApplication.CreateBuilder(args);


builder.Configuration.AddDbConfiguration(setup =>
{
	//setup.ConnectionString = "Server=127.0.0.1,14333;Database=db-config;User ID=sa;Password=Aa123456.;TrustServerCertificate=true;";
	setup.ReloadOnChange = true;
	setup.ReloadInterval = TimeSpan.FromSeconds(100);
});
builder.Services.Configure<WidgetOptions>(
	builder.Configuration.GetSection("WidgetOptions"));

var app = builder.Build();
app.MapGet("/widget-configuration", (IConfiguration config) =>
{
	var widgetOptions = config.GetSection("WidgetOptions:WidgetRoute").Get<string>();
	return widgetOptions;
});

app.MapGet("/widget-options", (IOptionsSnapshot<WidgetOptions> options) =>
{
	var widgetOptions = options.Value.WidgetRoute;
	return widgetOptions;
});
app.Run();

